import http from '@/utils/http'
import type { RoleAddOrEditParams, RoleParamsTypes, RoleResponseData, RoleResponse, RoleAddPremissionParams } from '../types/role'

enum API {
    RoleList_URL = '/api/acl/role/list',
    RoleAdd_URL = '/api/acl/role/add',
    RoleEdit_URl = '/api/acl/role/edit',
    RoleDelete_URL = '/api/acl/role/delete',
    RoleTree_URL = '/api/acl/menu/list',
    RoleAddPermission= '/api/acl/role/permission'
}

// 获取角色列表
export const reqRoleList = (data: RoleParamsTypes) => http.get<any, RoleResponseData>(API.RoleList_URL, { params: data })

// 新增角色
export const reqRoleAdd = (data: RoleAddOrEditParams) => http.post<any, RoleResponse>(API.RoleAdd_URL, data)

// 编辑角色
export const reqRoleEdit = (data: RoleAddOrEditParams) => http.post<any, RoleResponse>(API.RoleEdit_URl, data)

// 删除角色
export const reqRoleDelete = (id: string) => http.delete<any, RoleResponse>(API.RoleDelete_URL, { params: { id: id } })

// 分配权限列表
export const reqRoleTree = () => http.get<any, any>(API.RoleTree_URL)

// 分配权限
export const reqRolePermission =(data:RoleAddPremissionParams)=>http.post<any,RoleResponse>(API.RoleAddPermission,data)